package com.supermarket_project.utils;

import java.text.SimpleDateFormat;

public class ToSqlDate {
    public static java.sql.Date StringToDate(String string_date) {
        /**
         *str转date方法
         */
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        java.util.Date d = null;
        try {
            d = format.parse(string_date);
            java.sql.Date date = new java.sql.Date(d.getTime());
            return date;
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("日期类型转换失败！");
            return null;
        }
    }
}
